package me.stone.stanimeclient.core.data.repository

import me.stone.stanimeclient.core.data.db.AppDatabase
import me.stone.stanimeclient.core.data.db.SearchHistory
import me.stone.stanimeclient.core.data.db.SearchHistoryDao
import javax.inject.Inject

class SearchHistoryRepository @Inject constructor(
    private val appDatabase: AppDatabase
) : SearchHistoryDao by appDatabase.searchHistoryDao() {

    suspend fun insertHistory(history: String) {
        insert(history.historyEntity)
    }

    suspend fun deleteHistory(history: String) {
        delete(history.historyEntity)
    }

    private val String.historyEntity: SearchHistory
        get() = SearchHistory(this)

}